package com.cmcc.qx.ws.service.impl;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cmcc.qx.common.entity.Article;
import com.cmcc.qx.common.service.impl.BaseServiceImpl;
import com.cmcc.qx.ws.dao.ArticleDao;
import com.cmcc.qx.ws.service.ArticleService;

@Service("ArticleServiceImpl")
public class ArticleServiceImpl extends BaseServiceImpl implements ArticleService {

	@Resource(name = "ArticleDaoImpl")
	private ArticleDao dao;

	public Article queryById(Integer id) {
		return dao.queryById(id);
	}

	public List<Article> queryTop() {
		return dao.queryTop();
	}

	public List<Article> queryByDate(int start,int limit) {
		return dao.queryByDate(start,limit);
	}

	public List<Article> queryByType(int start,int limit ,Integer type) {
		return dao.queryByType(start,limit,type);
	}

	public Integer queryCnt(Integer type) {
		return dao.queryCnt(type);
	}

	public List<String> queryTag() {
		List<String> list = dao.queryTag();
		List<String> tags = new ArrayList<String>();
		for(String l : list){
			tags.addAll(Arrays.asList(l.split(" ")));
		}
		return tags;
	}

	public List<Article> queryArt() {
		return dao.queryArt();
	}

	public List<Article> queryRank() {
		return dao.queryRank();
	}

	public List<Article> selectArt(int start, int limit, String key) {
		return dao.selectArt(start, limit, key);
	}

	public Integer selectCntBykey(String key) {
		return dao.selectCntBykey(key);
	}

	public List<Article> queryTagArt(int start, int limit, String tag) {
		return dao.queryTagArt(start, limit, tag);
	}

	public Integer queryTagArtCnt(String tag) {
		return dao.queryTagArtCnt(tag);
	}

	public void addVisits(String artid) {
		dao.addVisits(artid);
	}

}
